package com.yksj.healthtalk.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * 自选商品分类实体
 * @author Administrator
 *
 */
public class ShopEntityClassify implements Serializable{

	String MERCHANT_ID;
	String CLASS_ID;
	String CLASS_NAME;
	String UPPER_CLASS_ID;
	String NOTES;
	String CLASS_TYPE;
	String CLASS_STATE;
	String STATE_TIME;
	String SUBLIST;
	String ADDRESS_ICON;
	
	public String getADDRESS_ICON() {
		return ADDRESS_ICON;
	}
	public void setADDRESS_ICON(String aDDRESS_ICON) {
		ADDRESS_ICON = aDDRESS_ICON;
	}
	public String getMERCHANT_ID() {
		return MERCHANT_ID;
	}
	public void setMERCHANT_ID(String mERCHANT_ID) {
		MERCHANT_ID = mERCHANT_ID;
	}
	public String getCLASS_ID() {
		return CLASS_ID;
	}
	public void setCLASS_ID(String cLASS_ID) {
		CLASS_ID = cLASS_ID;
	}
	public String getCLASS_NAME() {
		return CLASS_NAME;
	}
	public void setCLASS_NAME(String cLASS_NAME) {
		CLASS_NAME = cLASS_NAME;
	}
	public String getUPPER_CLASS_ID() {
		return UPPER_CLASS_ID;
	}
	public void setUPPER_CLASS_ID(String uPPER_CLASS_ID) {
		UPPER_CLASS_ID = uPPER_CLASS_ID;
	}
	public String getNOTES() {
		return NOTES;
	}
	public void setNOTES(String nOTES) {
		NOTES = nOTES;
	}
	public String getCLASS_TYPE() {
		return CLASS_TYPE;
	}
	public void setCLASS_TYPE(String cLASS_TYPE) {
		CLASS_TYPE = cLASS_TYPE;
	}
	public String getCLASS_STATE() {
		return CLASS_STATE;
	}
	public void setCLASS_STATE(String cLASS_STATE) {
		CLASS_STATE = cLASS_STATE;
	}
	public String getSTATE_TIME() {
		return STATE_TIME;
	}
	public void setSTATE_TIME(String sTATE_TIME) {
		STATE_TIME = sTATE_TIME;
	}
	public String getSUBLIST() {
		return SUBLIST;
	}
	public void setSUBLIST(String sUBLIST) {
		SUBLIST = sUBLIST;
	}

	public static Map<String,Object> parseJsonToInfo(String content) {
		List<ShopEntityClassify> groupList = new ArrayList<ShopEntityClassify>();
		List<List<ShopEntityClassify>> childList = new ArrayList<List<ShopEntityClassify>>();
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("group",groupList);
		map.put("child",childList);
		try {
			JSONArray json=new JSONArray(content);
			for (int i = 0; i < json.length(); i++) {
				JSONObject object = (JSONObject) json.get(i);
				ShopEntityClassify entitys=new ShopEntityClassify();
				entitys.setMERCHANT_ID(object.getString("MERCHANT_ID"));
				entitys.setCLASS_ID(object.getString("CLASS_ID"));
				entitys.setCLASS_NAME(object.getString("CLASS_NAME"));
				entitys.setUPPER_CLASS_ID(object.getString("UPPER_CLASS_ID"));
				entitys.setNOTES(object.getString("NOTES"));
				entitys.setCLASS_TYPE(object.getString("CLASS_TYPE"));
				entitys.setCLASS_STATE(object.getString("CLASS_STATE"));
				entitys.setSTATE_TIME(object.getString("STATE_TIME"));
				groupList.add(entitys);
				List<ShopEntityClassify> child = new ArrayList<ShopEntityClassify>();
				JSONArray jsonArray=(JSONArray)object.get("SUBLIST");
				for (int j = 0; j < jsonArray.length(); j++) {
					JSONObject o = (JSONObject) jsonArray.get(j);
					ShopEntityClassify entity=new ShopEntityClassify();
					entity.setMERCHANT_ID(o.getString("MERCHANT_ID"));
					entity.setCLASS_ID(o.getString("CLASS_ID"));
					entity.setCLASS_NAME(o.getString("CLASS_NAME"));
					entity.setUPPER_CLASS_ID(o.getString("UPPER_CLASS_ID"));
					entity.setNOTES(o.getString("NOTES"));
					entity.setCLASS_TYPE(o.getString("CLASS_TYPE"));
					entity.setCLASS_STATE(o.getString("CLASS_STATE"));
					entity.setSTATE_TIME(o.getString("STATE_TIME"));
					child.add(entity);
				}
				childList.add(child);
			}
			return map;
		} catch (JSONException e) {
			return map;
		}
	}
	public static List<ShopEntityClassify> parseJsonToInfoRead(String cotent) {
		List<ShopEntityClassify> groupList = new ArrayList<ShopEntityClassify>();
		try {
			JSONArray json=new JSONArray(cotent);
			for (int i = 0; i < json.length(); i++) {
				JSONObject object = (JSONObject) json.get(i);
				ShopEntityClassify entitys=new ShopEntityClassify();
				entitys.setMERCHANT_ID(object.getString("MERCHANT_ID"));
				entitys.setCLASS_ID(object.getString("CLASS_ID"));
				entitys.setCLASS_NAME(object.getString("CLASS_NAME"));
				entitys.setUPPER_CLASS_ID(object.getString("UPPER_CLASS_ID"));
				entitys.setNOTES(object.getString("NOTES"));
				if(object.has("ANDROID_CLASS_ICON")){
					entitys.setADDRESS_ICON(object.getString("ANDROID_CLASS_ICON"));
				}
				entitys.setCLASS_TYPE(object.getString("CLASS_TYPE"));
				entitys.setCLASS_STATE(object.getString("CLASS_STATE"));
				entitys.setSTATE_TIME(object.getString("STATE_TIME"));
				groupList.add(entitys);
			}
		} catch (Exception e) {
			
		}
		return groupList;
	}
	
	
	public static   List<ShopEntityClassify> SearchDoctorsToList(String content){
		List<ShopEntityClassify> groupList = new ArrayList<ShopEntityClassify>();
		try {
			JSONArray json=new JSONArray(content);
			for (int i = 0; i < json.length(); i++) {
				JSONObject object = (JSONObject) json.get(i);
				ShopEntityClassify entitys=new ShopEntityClassify();
				entitys.setMERCHANT_ID(object.getString("MERCHANT_ID"));
				entitys.setCLASS_ID(object.getString("CLASS_ID"));
				entitys.setCLASS_NAME(object.getString("CLASS_NAME"));
				entitys.setUPPER_CLASS_ID(object.getString("UPPER_CLASS_ID"));
				entitys.setNOTES(object.getString("NOTES"));
				if(object.has("ANDROID_CLASS_ICON")){
					entitys.setADDRESS_ICON(object.getString("ANDROID_CLASS_ICON"));
				}
				entitys.setCLASS_TYPE(object.getString("CLASS_TYPE"));
				entitys.setCLASS_STATE(object.getString("CLASS_STATE"));
				entitys.setSTATE_TIME(object.getString("STATE_TIME"));
				entitys.setSUBLIST(object.getString("SUBLIST"));
				groupList.add(entitys);
			}
		} catch (Exception e) {
			
		}
		return groupList;
		}
	/**
	 * 解析科室   只有两个参数
	 * @param content
	 * @return
	 */
	public static  List<ShopEntityClassify> SearchDoctorsKESHIToList(String content){
		List<ShopEntityClassify> groupList = new ArrayList<ShopEntityClassify>();
		try {
			JSONArray json=new JSONArray(content);
			for (int i = 0; i < json.length(); i++) {
				JSONObject object = (JSONObject) json.get(i);
				ShopEntityClassify entitys=new ShopEntityClassify();
				entitys.setCLASS_ID(object.getString("OFFICE_CODE"));//科室编码
				entitys.setCLASS_NAME(object.getString("OFFICE_NAME"));//科室名称
				groupList.add(entitys);
			}
		} catch (Exception e) {
		}
		return groupList;
		}
}
